package com.util;

import com.beans.PageInfo;

public class PageUtil {
    private PageUtil() {}

    public static PageInfo getPageInfo(int pageSize,int rowCount,int pageIndex) {
        PageInfo page = new PageInfo();
        page.setPageSize(  pageSize==0?10:pageSize  );
        page.setRowCount(  rowCount  );
        page.setPageIndex(  pageIndex==0?1:pageIndex  );

        page.setBeginRow( page.getPageSize()*(page.getPageIndex()-1) );
        page.setPageCount(  (rowCount+page.getPageSize()-1)/page.getPageSize()  );

        page.setHasNext(  page.getPageIndex()<page.getPageCount()  );
        page.setHasPre(  page.getPageIndex()>1  );
        return page;
    }
}
